import 'package:flutter/material.dart';

void main() => runApp(
      new MaterialApp(
        title: 'Drawer 抽屉组件示例',
        home: new LayoutDemo(),
      ),
    );

class LayoutDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Drawer 抽屉组件示例'),
      ),
      drawer: Drawer(
        child: ListView(
          children: <Widget>[
            // 设置用户信息，如头像、用户名、Email 等
            UserAccountsDrawerHeader(
              accountName: new Text(
                "ycher",
              ),
              accountEmail: new Text(
                "t.yuchen@qq.com",
              ),
              // 设置当前用户头像
              currentAccountPicture: new CircleAvatar(
//                backgroundImage: new AssetImage("images/1.jpeg"),
                backgroundImage: NetworkImage(
                    'https://avatars0.githubusercontent.com/u/20411817?s=460&u=103665344175e92585201318d8fdaaa976fafd81&v=4'),
              ),
              onDetailsPressed: () {},
              // 属性本来是用来设置当前用户的其它账号的头像，这里用二维码图片
              otherAccountsPictures: <Widget>[
                new Container(
//                  child: Image.asset('images/code.jpeg'),
                  child: Image.network(
                    'https://qr.api.cli.im/qr?data=Hello%2Bcao%2Bliao.&level=H&transparent=false&bgcolor=%23FFFFFF&forecolor=%23000000&blockpixel=12&marginblock=1&logourl=&size=800&kid=cliim&key=4bdf8c681d2cb6e9d218385b756b72e7',
                    fit: BoxFit.scaleDown,
                  ),
                ),
              ],
            ),
            // 导航栏菜单
            ListTile(
              leading: new CircleAvatar(child: Icon(Icons.color_lens)),
              title: Text('个性装扮'),
            ),
            ListTile(
              leading: new CircleAvatar(child: Icon(Icons.photo)),
              title: Text('我的相册'),
            ),
            ListTile(
              leading: new CircleAvatar(child: Icon(Icons.wifi)),
              title: Text('免流特权'),
            ),
          ],
        ),
      ),
    );
  }
}
